package com.wzapp.sitposture.task.scheduled;

import com.wzapp.sitposture.eshop.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class AutoExectueTask {

    @Autowired
    OrderService orderService;
    /**
     * 功能: 自动创建待支付订单<br/>
     * 每天0点10分0秒执行一次 <br/>
     *
     * @param
     * @return void
     * @author ql
     * @create 2019-02-03 11:01
     **/
    @Scheduled(cron = "0 10 0 * * ?")
    public void autoCreateOrder() {
        log.info("===============autoCreateOrder begin.===============");
        try {
            orderService.autoCreateOrder();
            log.info("===============autoCreateOrder end.===============");
        } catch (Exception e) {
            log.error("===============autoCreateOrder error end.===============");
        }
    }

    /**
     * 功能: 定时自动清理未支付的用户环信账号<br/>
     * 每天0点0分1秒执行一次 <br/>
     *
     * @param
     * @return void
     * @author ql
     * @create 2019-02-03 11:01
     **/
    @Scheduled(cron = "1 0 0 * * ?")
    public void autoDeleteUnpaidUserHuanXin() {
        log.info("===============autoDeleteUnpaidUserHuanXin begin.===============");
        try {
            orderService.autoDeleteUnpaidUserHuanXin();
            log.info("===============autoDeleteUnpaidUserHuanXin end.===============");
        } catch (Exception e) {
            log.error("===============autoDeleteUnpaidUserHuanXin error end.===============");
        }
    }

}
